/*
 * Copyright (C) 2021 Baidu, Inc. All Rights Reserved.
 */
package com.chukun.rpc.protocol.serialization;

import java.io.IOException;

/**
 * <p>定义序列化，反序列化接口<p/>
 *
 * @author chukun
 * @version 1.0
 * @since 1.0-SNAPSHOT
 */
public interface TinyRpcSerialization {

    /**
     * 序列化接口
     * @param message
     * @param <T>
     * @return
     * @throws IOException
     */
    <T> byte[] serialize(T message) throws IOException;

    /**
     * 反序列化接口
     * @param data
     * @param clazz
     * @param <T>
     * @return
     * @throws IOException
     */
    <T> T deserialize(byte[] data, Class<T> clazz) throws IOException;
}
